<template>
	<view class="rechargeBgc">
		<view class="rechargeBox">
			<view class="usableBalance">
				你的社区币可用余额为：<text>{{moneyVlu.money}}</text>个
			</view>
			<view class="moneyList me-fx-row-start-c">
				<view class="moneyListBox" :class="activeIndex == index? 'active':''" v-for="(item, index) in packageList" @click="packageBtn(item.id,index)">
					<view class="moneyListNum">
						<text>{{item.money}}</text>个
					</view>
					<view class="moneyListMoney">
						<text>{{item.price}}</text>元
					</view>
				</view>
			</view>
			<view class="selectWay">
				选择支付方式
			</view>
			<view class="WayList">
				<view class="wayBox me-fx-row-sb-c" @click="selectPay">
					<view class="wayBoxLeft me-fx-row-start-c">
						<image src="../../static/img/WeChat.png" mode=""></image>
						<view class="wayBoxLeftFont">
							微信
						</view>
					</view>
					<image src="../../static/img/get.png" mode="" class="selectPic" v-if="wxShow"></image>
				</view>
				<view class="wayBox me-fx-row-sb-c" @click="selectPay2">
					<view class="wayBoxRight me-fx-row-start-c">
						<image src="../../static/img/Alipay.png" mode=""></image>
						<view class="wayBoxRightFont">
							支付宝
						</view>
					</view>
					<image src="../../static/img/get.png" mode="" class="selectPic" v-if="zfbShow"></image>
				</view>
			</view>
		</view>
		<view class="chongzhiBtn" @click="chongzhiBtn">
			充值
		</view>
	</view>
</template>

<script>
	export default {
	
		data() {
			return {
				packageList: [],
				moneyVlu: 0.00,
				wxShow: true,
				zfbShow: false,
				id: '',
				type: '1',
				activeIndex: -1,
				nodes:[],
			}
		},
		created() {
			this.package()
			this.money()
		},
		methods: {
			package() {
				this.$u.get('/pay/package').then(res => {
						if (res) {
							console.log(res, 'dada')
							this.packageList = res.data.data
						}
					})
					.catch((res) => {

					})
			},
			money() {
				this.$u.get('/user/money').then(res => {
						if (res) {
							console.log(res, 'dada')
							this.moneyVlu = res.data
						}
					})
					.catch((res) => {

					})
			},
			packageBtn(id, index) {
				this.activeIndex = index
				this.id=id
			},
			chongzhiBtn() {
				let data = {
					id: this.id,
					type: this.type
				}
				this.$u.get('/pay/recharge',data ).then(res => {
						if (res) {
							uni.setStorageSync('html', res.data.result);
							uni.navigateTo({
								url:'../commonPage/pay'
							})
						}
					})
					.catch((res) => {

					})
			},
			selectPay() {
				this.wxShow = true
				this.zfbShow = false
				this.type=1
			},
			selectPay2() {
				this.wxShow = false
					this.zfbShow = true
					this.type=2
			},
		}
	}
</script>

<style>
	.active {
		border: 1px solid #5C14FF !important;
	}

	.rechargeBgc {
		width: 100%;
		height: 100%;
		background-color: #F5F5F5;
		/* margin-bottom: 110rpx; */

	}

	.rechargeBgc .rechargeBox {
		padding: 20rpx;
		box-sizing: border-box;
	}

	.usableBalance {
		font-size: 30rpx;
		color: rgba(200, 144, 47, 1);
		line-height: 40rpx;
		padding: 32rpx 0;
	}

	.moneyList {
		flex-wrap: wrap;
		align-content: flex-start
	}

	.moneyList .moneyListBox {
		width: 30%;
		width: 222rpx;
		height: 170rpx;
		background: rgba(255, 255, 255, 1);
		border-radius: 8rpx;
		margin-top: 20rpx;
		margin-right: 3%;
		text-align: center;
		color: #666666;
	}

	.moneyList .moneyListBox:nth-last-of-type(3n) {
		margin-right: 0;
	}

	.moneyList .moneyListNum {
		margin-top: 30rpx;
	}

	.moneyList .moneyListNum text {
		font-size: 48rpx;
		color: #333333;
	}

	.moneyList .moneyListMoney {
		font-size: 28rpx;
		margin-top: 10rpx;
	}

	.selectWay {
		font-size: 28rpx;
		color: rgba(102, 102, 102, 1);
		padding: 50rpx 22rpx;
		box-sizing: border-box;
	}

	.WayList {
		width: 100%;
		background-color: white;
		border-radius: 16rpx;
	}

	.WayList .wayBox {
		height: 120rpx;
		padding: 0 30rpx;
	}

	.wayBox:nth-of-type(2) {
		border-top: 1rpx solid #F5F5F5;
	}

	.wayBoxLeft image,
	.wayBoxRight image {
		width: 52rpx;
		height: 52rpx;
		margin-right: 13rpx;
	}

	.selectPic {
		width: 48rpx;
		height: 32rpx;
	}

	.wayBoxRightFont,
	.wayBoxLeftFont {
		font-size: 32rpx;
		color: rgba(51, 51, 51, 1);
	}

	.chongzhiBtn {
		position: fixed;
		bottom: 0;
		left: 0;
		width: 100%;
		height: 110rpx;
		background: rgba(92, 20, 255, 1);
		line-height: 110rpx;
		text-align: center;
		color: white;
		font-size: 32rpx;
		font-weight: 700;
	}
</style>
